package com.neusoft.elmboot.controller;

import com.neusoft.elmboot.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neusoft.elmboot.po.User;
import com.neusoft.elmboot.service.UserService;

/**
 * 用户
 * Controller
 */
@Slf4j
@RestController
@RequestMapping("/UserController")
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("/getUserByIdByPass")
    public Result<User> getUserByIdByPass(User user) throws Exception{
        log.info("调用接口：用户登录");
        return Result.success(userService.getUserByIdByPass(user));
    }

    @RequestMapping("/getUserById")
    public Result<Integer> getUserById(User user) throws Exception{
        log.info("调用接口：根据ID查询用户信息");
        return Result.success(userService.getUserById(user.getUserId()));
    }

    @RequestMapping("/saveUser")
    public Result<Integer> saveUser(User user) throws Exception{
        log.info("调用接口：用户注册");
        return Result.success(userService.saveUser(user));
    }

    @RequestMapping("/getProfileByUserId")
    public Result<String> getProfileByUserId(User user) throws Exception{
        log.info("调用接口：根据用户ID查询头像");
        return Result.success(userService.getProfileByUserId(user));
    }
}
